#ifndef ResultItem_H
#define ResultItem_H

#include "ModelItems/TreeItem.h"
#include "..\..\core\src\AssetManager.h"
#include "..\..\core\src\container\ResponseAttribute.h"

namespace Xps
{
	class ResultItem : public TreeItem
	{
	public:
		ResultItem(XpsAssets::AssetManager* am, int id, int pid = -1) : TreeItem(am,id,ModelItemType::RESULT, pid)
		{
			asset = am->getResult(id);
			setIcon(QIcon(":/rs/images/result.png"));
					
		};

		QVariant ResultItem::data (int role) const
		{
			XpsAssets::Result* r;
			r = (XpsAssets::Result*) asset;
			
			if (role == Qt::EditRole || role == Qt::DisplayRole)
			{
				r = (XpsAssets::Result*) asset;
				return QString("%1 %2").arg(r->id(),3,10,QChar('0')).arg(r->name());
			}
				
			return TreeItem::data(role);
		}

		void ResultItem::setData ( const QVariant & value, int role)
		{
			if (role != Qt::EditRole) 
				return TreeItem::setData(value,role);

			XpsAssets::Result* rslt = (XpsAssets::Result*) asset;
			rslt->setName(value.toString());
		}
	};
}
#endif